//
//  UIBarButtonItem+Category.swift
//  cxd4iphone
//
//  Created by hexy on 11/23/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    
    convenience init(title: String, image: UIImage, target: AnyObject?, action: Selector) {
        
        self.init()
        
        let btn = UIButton(title: title, titleColor: UIColor.whiteColor(), titleSize: 15, bgColor: UIColor.clearColor(), normalImage: image)
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
//        btn.backgroundColor = UIColor.orangeColor()
        self.customView = btn
    }
    
    convenience init(title: String, image: UIImage) {
        
        self.init()
        
        let btn = RLButton()
        btn.setTitle(title, forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.titleLabel?.font = xx_fontOfSize(size: 14)
        btn.setImage(image, forState: .Normal)
        btn.sizeToFit()
//                btn.backgroundColor = UIColor.orangeColor()
        self.customView = btn
    }
    
    convenience init(target: AnyObject?, action: Selector) {
        
        self.init()
        
        let btn = RLButton()
        btn.setTitle("筛选", forState: .Normal)
        btn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        btn.titleLabel?.font = xx_fontOfSize(size: 14)
        btn.setImage(UIImage(named: "invest_indector"), forState: .Normal)
        btn.sizeToFit()
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        //                btn.backgroundColor = UIColor.orangeColor()
        self.customView = btn
    }
}